/**
  *  Module
  *
  * Description
  */
angular.
  module('sfhtHaitaoCmsApp').
  controller('ComDatePickerCtrl', function($scope, $modalInstance, date, mode) {

    $scope.cdate = date;

    var tomorrow = new Date();
    tomorrow.setDate(tomorrow.getDate() + 1);
    var afterTomorrow = new Date();
    afterTomorrow.setDate(tomorrow.getDate() + 2);
    $scope.events = [{
      date: tomorrow,
      status: 'full'
    }, {
      date: afterTomorrow,
      status: 'partially'
    }];

    $scope.getDayClass = function(date) {
      if (mode === 'day') {
        var dayToCheck = new Date(date).setHours(0, 0, 0, 0);

        for (var i = 0; i < $scope.events.length; i++) {
          var currentDay = new Date($scope.events[i].date).setHours(0, 0, 0, 0);

          if (dayToCheck === currentDay) {
            return $scope.events[i].status;
          }
        }
      }

      return '';
    };

    $scope.ok = function(){
      $modalInstance.close($scope.cdate);
    };

    $scope.cancel = function() {
      $modalInstance.dismiss('cancel');
    };

  });